package com.example.opengl.camera

import android.util.Log
import android.view.View
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.example.opengl.utils.OnRepeatClickListener

/**
 * @author: Mr.You
 * @create: 2023-09-27 11:28
 * @description: viewModel
 **/
class CameraViewModel() : ViewModel(), ICameraPreview {

    val switchCameraLiveData = MutableLiveData<Boolean>()

    val addFilterLiveData = MutableLiveData<Boolean>()

    val addBeautyFilterLiveData = MutableLiveData<Boolean>()

    val recordVideoLiveData = MutableLiveData<Boolean>(null)

    override val switchCamera = View.OnClickListener {
        switchCameraLiveData.value = true
    }

    override val addFilter: OnRepeatClickListener
        get() = object : OnRepeatClickListener() {
            override fun onRepeatClick(v: View) {
                Log.i("TAGass", "initView: 12")
             addFilterLiveData.value = true
            }

        }
    override val addBeauty: OnRepeatClickListener
        get() = object : OnRepeatClickListener() {
            override fun onRepeatClick(v: View) {
                addBeautyFilterLiveData.value = true
            }

        }
    override val recordVideo: OnRepeatClickListener
        get() = object :OnRepeatClickListener(){
            override fun onRepeatClick(v: View) {
                recordVideoLiveData.value = !(recordVideoLiveData.value?:false)
            }
        }


}